import java.io.File;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-08-14
 * Time: 17:15
 */
public class demo1 {
    public static void main1(String[] args) throws IOException {
        File file = new File("C:\\Vampire\\Directory1\\test.txt");
        System.out.println("File对象的父目录文件路径: " + file.getParent());
        System.out.println("File对象的文件名称: " + file.getName());
        System.out.println("File对象的文件路径: " + file.getPath());
        System.out.println("File对象的绝对路径: " + file.getAbsolutePath());
        System.out.println(file.getCanonicalPath());
    }

    public static void main(String[] args) throws IOException {
        File file = new File("./text.txt");
        System.out.println("File对象的父目录文件路径: " + file.getParent());
        System.out.println("File对象的文件名称: " + file.getName());
        System.out.println("File对象的文件路径: " + file.getPath());
        System.out.println("File对象的绝对路径: " + file.getAbsolutePath());
        System.out.println(file.getCanonicalPath());
    }

    public static void main2(String[] args) throws IOException {
        File file = new File("../text.txt");
        System.out.println("File对象的父目录文件路径: " + file.getParent());
        System.out.println("File对象的文件名称: " + file.getName());
        System.out.println("File对象的文件路径: " + file.getPath());
        System.out.println("File对象的绝对路径: " + file.getAbsolutePath());
        System.out.println("返回File对象的修饰过的绝对路径: " + file.getCanonicalPath());
    }
}
